package multithreadedgui.model;

/**
 * Use at own risk.
 * Creation data:
 * User: Alex
 * Date: 12/04/12
 * Time: 20:07
 */
public class PiComputer {
    // This might take a while
    public static double calculatePi() {
        double denominator=1.0, pi=1.0;
        for(long i = 1; i > 0; i++)
        {
            denominator += 2.0;
            pi = pi + (i%2 == 0? 1: -1) * (1 / denominator);

            if(Math.abs(Math.PI - pi * 4) < 0.000000005)
                break;
        }
        return pi*4;
    }
}
